package com.draven

import java.util.List

import com.alibaba.fastjson.JSON

/**
  * Created by Draven on 2018/7/10.
  * Email:hjx@qiandw.com
  */
package object tongzhou {

  val SUCCESS = ("000000", "操作成功", "")

  val SYS_MSG_SUCCESS = (200, "操作成功", "")

  val SYS_MSG_ILLEGAL_ARGUMENT = (99001, "", "参数有误")

  val SYS_MSG_ERROR = (99999, "", "系统错误")

  val SYS_MSG_PWD_ERROR = (99902, "", "用户名或密码错误")

  val SYS_MSG_VERIFYCODE_ERROR = (99903, "", "验证码错误")

  val SYS_SESSION_TIME_OUT = (99904, "", "登录超时")

  val SYS_MSG_OBJ_NOT_EXISTS = (99905, "", "对象不存在")

  val SYS_MSG_NO_LOGIN = (99906, "", "对象不存在")

  val SYS_MSG_OBJ_ENTERPRISE_NOT_OPEN_ANXINQIAN = (99910, "", "企业未开通安心签")

  val SYS_MSG_OBJ_ENTERPRISE_NOT_OPEN_CUNGUAN = (99911, "", "企业未开通存管")

  val SESSION_USER_KEY = "QVbjRuq9NYQ7mjT"

  val DEFAULT_PAGE_NO: Integer = 1 //默认页数

  val DEFAULT_PAGE_SIZE: Integer = 20 //默认每页数据量

  /**
    * 附件类型
    */
  val ATTACHMENT_TYPE_BUSINESS_LICENCE = 0 //银业执照

  val ATTACHMENT_TYPE_CERTIFICATE_OF_GUARANTEE = 1 //担保函

  val ATTACHMENT_TYPE_OTHER = 2 // 其他

  val ATTACHMENT_TYPE_HAND_OVER_SHEET = 3 // 交接单

  /**
    * 借款类型
    */

  /**
    * 借款项目信息状态
    */
  val PROJECT_STATUS_DRAFT = 0 //草稿

  val PROJECT_STATUS_APPROVING = 1 //审核中

  /**
    * 借款类型
    */
  val BRO_TYPE_ALONE = 0 //独立借款

  val BRO_TYPE_N = 1 //1+N

  def listToJsonStrWithTotalCount[T](total:Integer,data: List[T]): String = {
    var json = ""
    if (!data.isEmpty) {
      val dataJsonStr = JSON.toJSON(data)
      json = "{\"total\":" + total + ",\"rows\":" + dataJsonStr + "}"
    } else {
      json = "{\"total\":0,\"rows\":[]}"
    }
    json
  }
}
